package com.hellobike.haxing.modules.wms.mapper;

import java.util.List;

import com.hellobike.haxing.modules.wms.dto.ExportAsnDto;
import org.apache.ibatis.annotations.Param;
import com.hellobike.haxing.modules.wms.entity.AsnHeader;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

/**
 * @Description: t_wms_asn_header
 * @Author: haxing-boot
 * @Date:   2020-01-09
 * @Version: V1.0
 */
public interface AsnHeaderMapper extends BaseMapper<AsnHeader> {

    @Select("SELECT sp.spu_name,sk.sku_code,sk.barcode,sp.purchase_spec,sp.purchase_spec_unit,s.supplier_name, " +
            "d.purchase_count,d.received_good_count+d.received_bad_count as received_count,d.received_good_count,d.received_bad_count  " +
            "FROM t_wms_asn_detail as d  " +
            "LEFT JOIN t_wms_asn_header as h ON h.id=d.asn_header_id " +
            "LEFT JOIN t_supplier as s ON s.id=h.supplier_id " +
            "LEFT JOIN t_sku as sk ON sk.id=d.sku_id " +
            "LEFT JOIN t_spu as sp ON sp.id=sk.spu_id " +
            "WHERE d.deleted=0 AND d.asn_header_id =#{asnId}")
    List<ExportAsnDto> exportAsn(@Param("asnId") Long asnId);
}
